const OPEN_MODAL = 'OPEN_MODAL';

let openedIndex = 0;
const openModal = (title, content) => ({
  type: OPEN_MODAL,
  index: openedIndex++,
  title,
  content
});

export const actions = {
  openModal
}

const initialState = {
  open: false,
  opened: 0,
};

const reducer = (state = initialState, action) => {
  switch (action.type) {
    case OPEN_MODAL:
      return Object.assign({}, state, {open: true, opened: state.opened++});
    default:
      return state;
  }

};
export default reducer;
